---
id: "scoped-polymorphic-type"
keywords: ["scoped", "polymorphic"]
name: "'a."
summary: "This is a `scoped polymorphic type`."
category: "languageconstructs"
---

In ReScript, polymorphic functions can only deal with one specific type. When they are called, their type gets fixed.
For instance this logging function is bound in a polymorphic way as you can see by the type parameter (`'a`).

```res
type logger<'a> = { log: 'a => unit}

@module("jsAPI") external getLogger: unit => logger<'a> = "getLogger"

let myLogger = getLogger()

myLogger.log("Hello, ReScript!")
myLogger.log(42) // Type error!
```

Scoped polymorphic types make such behavior possible, in a type-safe way. See the `'a.` in the example below.

### Example

<CodeTab labels={["ReScript", "JS Output"]}>

```res
type logger = { log: 'a. 'a => unit}

@module("jsAPI") external getLogger: unit => logger = "getLogger"

let myLogger = getLogger()

myLogger.log("Hello, ReScript!")
myLogger.log(42) // Ok!
```

```js
var JsAPI = require("jsAPI");

var myLogger = JsAPI.getLogger();

myLogger.log("Hello, ReScript!");

myLogger.log(42);
```

</CodeTab>

### References

- [Scoped Polymorphic Types](../docs/manual/scoped-polymorphic-types.mdx)
